<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>商业联盟</title>
		<script src="/public/sp/js/mui.min.js"></script>
		<link href="/public/sp/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="/public/sp/css/style.css" />
		<link rel="stylesheet" href="/public/sp/css/iconfont.css" />
		<link rel="stylesheet" href="/public/sp/css/me.css" />
		<link rel="stylesheet" href="/public/sp/css/shoupiao.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">商业联盟</h1>
		</header>
		{include file="bottom" /}
		<div class="mui-content cash_content" style="padding-top: 55px;">
			<div id="slider" class="mui-slider sj_slider">
				<div class="mui-slider-group mui-slider-loop">
					{if $ads} {foreach name="ads" item="ad"}
					<div class="mui-slider-item">
						<a href="{$ad.url}">
							<img src="{$ad.thumb}">
						</a>
					</div>
					{/foreach}
					<!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
					<div class="mui-slider-item mui-slider-item-duplicate">
						<a href="{$ads[0]['url']}">
							<img src="{$ads[0]['thumb']}">
						</a>
					</div>
					{else/}
					<div class="mui-slider-item">
						<img id="second" src="/public/sp/images/banner_hhr.jpg">
					</div>
					{/if}
				</div>
				<div class="mui-slider-indicator">
					<div class="mui-indicator mui-active"></div>
					<div class="mui-indicator"></div>
					<div class="mui-indicator"></div>
					<div class="mui-indicator"></div>
				</div>
			</div>
			<div class="sj_listbox">
				<ul class="mui-table-view mui-grid-view mui-grid-9">
					{foreach name="types" item="v"}
					<li data-id="{$v.id}"  class="mui-table-view-cell mui-media">
						<a href="#">
							<span class="mui-icon iconfont ">
								<img src="{$v.img}" />
							</span>
							<div class="mui-media-body">{$v.name}</div>
						</a>
					</li>
					{/foreach}
				</ul>
				<ul class="sj_list">

				</ul>
				<p id="bt" style="color: #fff;text-align: center;display: none;">数据已加载完毕</p>
			</div>
		</div>
		<input type="hidden" id="page" value="1" />
		<input type="hidden" id="end" value="0" />
		{include file="bottom" /}
	</body>
	<div class="share-tip" id="share-tip" style="display: none;">
		<img src="/public/static/images/share.png">
		<a class="a-know" id="clostShare-tip" href="javascript:$('#share-tip').hide()">我知道了</a>
	</div>
	<script src="/public/static/js/jquery.min.js"></script>
	<script src="/public/static/layui/layui.all.js"></script>
	<script src="/public/static/js/help.js "></script>
	<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js "></script>
	<script>
		var gurl = "{$url}";
		desc = "{$share_content}";
		var news = {
			"title": "{$share_title}",
			"desc": desc,
			"imgUrl": "https://" + document.domain + "/public/sp/images/logo.png",
			"link": gurl
		};
		share_set(news);
	</script>
	<script>
		var gallery = mui('.mui-slider');
		gallery.slider({
			interval: 3000 //自动轮播周期，若为0则不自动播放，默认为0；
		});
		get_data(0);
		$(".sj_listbox li").click(function(){
			$(".sj_listbox  .active").removeClass("active");
			$(this).addClass("active");
			get_data($(this).data("id"));
		})
		function get_data(typeid) {
			var index = layer.load(0, {
				shade: false,
				time: 1.5 * 1000
			});
			$(".layui-layer-loading").css("left", "40%");
			$.ajax({
				type: "post",
				data: {
					page: $("#page").val(),
					typeid: typeid
				},
				url: "{:url('index/index/sj_list')}",
				success: function(data) {
					var list = data.list;
					var html = "";
					if(list&&list.length>0) {
						for(var i = 0; i < list.length; i++) {
							var log = list[i];
							var url="/index/index/shop_page?agent_id="+log.id;
							var activity = log['activity'].substring(0, 12);
							html += '<li>' +
								'<a href="'+url+'">' +
								'<div class="left"><img class="layui-upload-img" src="' + log['thumb'] + '"></div>' +
								'<div class="right">' +
								'<div class="name">' + log['agent_name'] + '</div>' +
								'<div class="sj_hdbox">' +
								'<p>' + activity + '...</p>' +
								'</div>' +
								'<div class="adress"><span class="iconfont icon-dingwei"></span>' + log['address'] + '</div>' +
								'</div>' +
								'</a>' +
								'</li>';
						}
					} else {
						html = '<div class="none">' +
							'<p class="iconfont icon-404"></p>' +
							'<p>很抱歉，暂无记录</p></div>';
					}
					layer.close(index);
					$(".sj_list").html(html);

				}
			});
		}
		$(window).scroll(function() {
			var val=$("#end").val();
			var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight);
			//视窗的高度
			var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
			//隐藏的高度
			var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
			if(pageHeight - viewportHeight - scrollHeight < 40) { 
				if(val==1){
						return;
				}
				var index = layer.load(0, {
					shade: false,
					time: 1.5 * 1000
				});
				$(".layui-layer-loading").css("left", "40%");
				$.ajax({
					type: "post",
					data: {
						page: parseFloat($("#page").val()) + 1
					},
					url: "{:url('/index/index/sj_list')}",
					success: function(data) {
						var list = data.list;
						var html = "";
						if(list&&list.length>0) {
							$("#page").val(parseFloat($("#page").val()) + 1);
							for(var i = 0; i < list.length; i++) {
								var log = list[i];
								var activity = log['activity'].substring(0, 12);
								var url="index/index/shop_page?agent_id="+log.id;
								html += '<li>' +
									'<a href="'+url+'">' +
									'<div class="left"><img class="layui-upload-img" src="' + log['thumb'] + '"></div>' +
									'<div class="right">' +
									'<div class="name">' + log['agent_name'] + '</div>' +
									'<div class="sj_hdbox">' +
									'<p>' + activity + '...</p>' +
									'</div>' +
									'<div class="adress"><span class="iconfont icon-dingwei"></span>' + log['address'] + '</div>' +
									'</div>' +
									'</a>' +
									'</li>';
							}
							$(".sj_list").append(html);
						} else {
							$("#end").val(1);
							$("#bt").show();
						}
						layer.close(index);
						

					}
				});

			}
		})

</script>

</html>